//! ## Helper Macros for Returning Error Codes
//!
//! The `check!` macro is used to check the result of a function call and return the
//! error code if it failed.

/// Check the result of a function call and return the error code if it failed.
macro_rules! check {
    ($result:expr) => {
        match $result {
            Ok(value) => value,
            Err(::cs2s::error::Error::LibcError { errno }) => return -errno,
            Err(err) => return -0x80000000 + err.discriminant() as i32,
        }
    };
}
pub(crate) use check;
